package com.rongshu.view.userInfo.adapter.pageadapter;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.rongshu.utils.Constant;
import com.rongshu.view.userInfo.fragment.CollectedArticleFragment;

import java.util.List;

public class PublishAuditDraftPagerAdapter extends FragmentPagerAdapter {

    //标题
    private List<String> titles = null;
    //文集id
    private int serialize = 0;

    public PublishAuditDraftPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    /**
     * 设置标题
     *
     * @param list
     */
    public void setTitles(List<String> list) {
        this.titles = list;
    }

    /**
     * 文集id
     *
     * @param serialize
     */
    public void setSerialize(int serialize) {
        this.serialize = serialize;
    }

    @Override
    public Fragment getItem(int position) {
        return createForNoExpand(position);
    }

    @Override
    public int getCount() {
        return titles.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    private Fragment createForNoExpand(int position) {
        Fragment fragment = null;
        fragment = new CollectedArticleFragment();
        Bundle bundle = new Bundle();
        bundle.putInt(Constant.INTENT_MESSAGE, serialize);
        bundle.putInt(Constant.INTENT_TYPE, position + 1);
        fragment.setArguments(bundle);
        return fragment;
    }
}
